package vn.edu.saigontech.ncms.web.system;

import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.AbstractValidator;

@SuppressWarnings("serial")
public class ValidateDiscountItemAction extends AbstractValidator {
	private String percent;
	private String name;
	
	@Override
	public String check() {
		if(Checker.isEmpty(this.percent)) {
			this.sendKeyError("validator.required", "percent");
		}
		if(!Checker.isInteger(this.percent)) {
			this.sendKeyError("validator.integer", "percent");
		}
		int value = Integer.parseInt(this.percent);
		if(value < 0 || value > 100) {
			this.sendKeyError("validator.between", "percent", "0", "100");
		}
		if(Checker.isEmpty(this.name)) 
			this.sendKeyError("validator.required", "name");
		return this.toSuccess();
	}

	

	public String getPercent() {
		return percent;
	}



	public void setPercent(String percent) {
		this.percent = percent;
	}



	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static void main(String[] args) {
	}
}
